package de.staxx6.bomber.box;

import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;

import de.staxx6.bomber.GameState;
import de.staxx6.bomber.Stats;

public class BrickBox extends BoxBomber{
	
	private Node fieldNode;
	private RigidBodyControl physic;
	
	public BrickBox(final float newX, final float newY, Node newFieldNode) {
		super(newX, newY, "BrickBox");
		this.fieldNode = newFieldNode;
		
		createBox();
		Stats.BRICKBOXES++;
		
		System.out.println("BrickBox@ X:" + x + " Y: " + y);
	}
	
	private void createBox() {
		Geometry geo_Box = new Geometry("Brick", box);
		Material mat_Box = new Material(GameState.ASSETMANAGER, "Common/MatDefs/Misc/Unshaded.j3md");
		mat_Box.setTexture("ColorMap", GameState.ASSETMANAGER.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
		geo_Box.setMaterial(mat_Box);
		boxNode.attachChild(geo_Box);
		
		makeRigidBodyControl();
	}
	
	private void makeRigidBodyControl() {
		fieldNode.attachChild(boxNode);
		physic = new RigidBodyControl(0.0f);
		boxNode.addControl(physic);
		GameState.BULLETAPPSTATE.getPhysicsSpace().add(physic);
	}	
	
	public RigidBodyControl getPhysic() {
		return physic;
	}
}
